/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2011
Version 0.1
=======================================================*/
Configuration = function(xml) {
	var xmlDoc = parseXML(xml);

	this.type = 'c';
	this.id = xmlDoc.getElementsByTagName("ID")[0].childNodes[0].nodeValue;
	this.rwan = xmlDoc.getElementsByTagName("RWan")[0].childNodes[0].nodeValue;
	this.rusers = xmlDoc.getElementsByTagName("RUsers")[0].childNodes[0].nodeValue;
	this.name = xmlDoc.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
	this.updated = xmlDoc.getElementsByTagName("Updated")[0].childNodes[0].nodeValue;
	this.creation = xmlDoc.getElementsByTagName("Creation")[0].childNodes[0].nodeValue;
	this.updatedStr = xmlDoc.getElementsByTagName("UpdatedStr")[0].childNodes[0].nodeValue;
	this.creationStr = xmlDoc.getElementsByTagName("CreationStr")[0].childNodes[0].nodeValue;
	if(xmlDoc.getElementsByTagName("Description")[0].childNodes.length != 0)
		this.description = xmlDoc.getElementsByTagName("Description")[0].childNodes[0].nodeValue;
	else
		this.description = ""; 
		
	this.deviceCount = xmlDoc.getElementsByTagName("DeviceCount")[0].childNodes[0].nodeValue;
	
	if(xmlDoc.getElementsByTagName("ConfigFileName")[0].childNodes.length != 0)
		this.configFileName = xmlDoc.getElementsByTagName("ConfigFileName")[0].childNodes[0].nodeValue;
	else
		this.configFileName = ""; 

	if(xmlDoc.getElementsByTagName("CFSize").length != 0 && xmlDoc.getElementsByTagName("CFSize")[0].childNodes.length != 0)
		this.cfSize = xmlDoc.getElementsByTagName("CFSize")[0].childNodes[0].nodeValue;
	else
		this.cfSize = ""; 

	if(xmlDoc.getElementsByTagName("CFType").length != 0 && xmlDoc.getElementsByTagName("CFType")[0].childNodes.length != 0)
		this.cfType = xmlDoc.getElementsByTagName("CFType")[0].childNodes[0].nodeValue;
	else
		this.cfType = ""; 

	if(xmlDoc.getElementsByTagName("CFReboot").length != 0 && xmlDoc.getElementsByTagName("CFReboot")[0].childNodes.length != 0)
		this.cfReboot = xmlDoc.getElementsByTagName("CFReboot")[0].childNodes[0].nodeValue;
	else
		this.cfReboot = ""; 

	if(xmlDoc.getElementsByTagName("CFRelease").length != 0 && xmlDoc.getElementsByTagName("CFRelease")[0].childNodes.length != 0)
		this.cfRelease = xmlDoc.getElementsByTagName("CFRelease")[0].childNodes[0].nodeValue;
	else
		this.cfRelease = ""; 

	if(xmlDoc.getElementsByTagName("CFCreation").length != 0 && xmlDoc.getElementsByTagName("CFCreation")[0].childNodes.length != 0)
		this.cfCreation = xmlDoc.getElementsByTagName("CFCreation")[0].childNodes[0].nodeValue;
	else
		this.cfCreation = ""; 

	if(xmlDoc.getElementsByTagName("CFLicenseID").length != 0 && xmlDoc.getElementsByTagName("CFLicenseID")[0].childNodes.length != 0)
		this.cfLicenseID = xmlDoc.getElementsByTagName("CFLicenseID")[0].childNodes[0].nodeValue;
	else
		this.cfLicenseID = ""; 

	if(xmlDoc.getElementsByTagName("CFVoipSounds").length != 0 && xmlDoc.getElementsByTagName("CFVoipSounds")[0].childNodes.length != 0)
		this.cfVoipSounds = xmlDoc.getElementsByTagName("CFVoipSounds")[0].childNodes[0].nodeValue;
	else
		this.cfVoipSounds = ""; 

	if(xmlDoc.getElementsByTagName("CFDescription").length != 0 && xmlDoc.getElementsByTagName("CFDescription")[0].childNodes.length != 0)
		this.cfDescription = xmlDoc.getElementsByTagName("CFDescription")[0].childNodes[0].nodeValue;
	else
		this.cfDescription = ""; 

	this.tid = this.type+this.id;
	this.text = this.name + " (" + this.deviceCount + ")";
};

Ext.reg('appconfiguration', Configuration);